package cn.tust.edu.db;

import java.util.Properties;

import javax.sql.DataSource;

import org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory;

public class MyDataSource {
public static DataSource dataSource =null;
private MyDataSource(){}
public static DataSource getDataSource(){
	if(dataSource==null){
		try{
			Properties prop=new Properties();
			prop.load(MyDataSource.class.getClassLoader().getResourceAsStream("db.properties"));
			dataSource=BasicDataSourceFactory.createDataSource(prop);
		}catch(Exception e){
			System.out.println("生成数据库连接也错误："+e.getMessage());
		}
	}
	return dataSource;

}
}
